//**********************************************************
//    File Name: Person.cs
//    Author: Team Motif
//    Date Created : 04/13/2007
//    Current Owner: Team Motif 
//                                                                            
//    Purpose: 
//    This class provides the functions needed to create, 
//    manipulate or read the attributes of a Person
//
//	  Copyright 2007
//**********************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace Library
{
    public enum SexType
    {
        Male,
        Female
    };

    public class Person
    {   
        /// <summary>
        /// -------------------------------------------------------------------------------
        /// The default constructor for person class
        /// -------------------------------------------------------------------------------
        /// </summary>
        public Person()
        {
            // default constructor;
            mUserID = GenerateUserID();
            mDateCreated = new DateTime();
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// The basic constructor of a person.  
        /// -------------------------------------------------------------------------------
        /// </summary>
        public Person(string firstName, string lastName)
        {
            SetName(firstName, lastName);
            mUserID = GenerateUserID();
            mDateCreated = new DateTime();
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// The complete constructor of a person.  
        /// -------------------------------------------------------------------------------
        /// </summary>
        public Person(string firstName, string lastName, DateTime dateOfBirth)
        {
            SetName(firstName, lastName);
            mDateOfBirth = dateOfBirth;
            mUserID = GenerateUserID();
            mDateCreated = new DateTime();
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Get the usesr ID of the person 
        /// -------------------------------------------------------------------------------
        /// </summary>
        public long GetUserID()
        {
            return mUserID;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the first name
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetFirstName()
        {
            return mFirstName;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the first name of the person.
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetFirstName(String name)
        {
            // should probably verfiy this operation with the user
            mFirstName = name;
            TouchRecord();
        }


        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the first and last name of the person
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetName(string firstName, string lastName)
        {
            mFirstName = firstName;
            mLastName = lastName;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the first, middle, and last name of the person
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetName(string firstName, string middleName, string lastName)
        {
            mFirstName = firstName;
            mMiddleName = middleName;
            mLastName = lastName;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the middle name of the person
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetMiddleName(string middleName)
        {
            mMiddleName = middleName;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the middle name
        /// -------------------------------------------------------------------------------
        /// </summary>
        public string GetMiddleName()
        {
            return mMiddleName;
        }


        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the last name
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetLastName()
        {
            return mLastName;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the last name of the person.
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetLastName(String name)
        {
            // should probably verfiy this operation with the user
            mLastName = name;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Gets address 1
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetAddress1()
        {
            return mAddress1;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets address 1
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetAddress1(String address)
        {
            mAddress1 = address;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the User ID for a person
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetUserID(long UID)
        {
            mUserID = UID;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Gets address 2
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetAddress2()
        {
            return mAddress2;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets address 2
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetAddress2(String address)
        {
            mAddress2 = address;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Gets the city name
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetCity()
        {
            return mCity;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the city name
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetCity(String city)
        {
            mCity = city;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the state
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetState()
        {
            return mState;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the state
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetState(String state)
        {
            mState = state;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the zip code
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetZipCode()
        {
            return mZipCode;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the zip code
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetZipCode(String zip)
        {
            mZipCode = zip;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns date of birth
        /// -------------------------------------------------------------------------------
        /// </summary>
        public DateTime GetDateOfBirth()
        {
            return mDateOfBirth;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets date of birth.
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetDateOfBirth(DateTime time)
        {
            // should probably verfiy this with the user.
            mDateOfBirth = time;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the type of sex
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetSexType(String sex)
        {
            mSexType = sex;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns Male/Female sex type
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetSexType()
        {
            return mSexType;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the type of User
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetUserType(char userType)
        {
            mUserType = userType;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets phone number 1
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetPhoneNumber1(String number)
        {
            mPhoneNumber1 = number;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns Phone number 1
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetPhoneNumber1()
        {
            return mPhoneNumber1;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets phone number 2
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetPhoneNumber2(String number)
        {
            mPhoneNumber2 = number;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns Phone number 2
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetPhoneNumber2()
        {
            return mPhoneNumber2;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets phone number 3
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetPhoneNumber3(String number)
        {
            mPhoneNumber3 = number;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns Phone number 3
        /// -------------------------------------------------------------------------------
        /// </summary>
        public String GetPhoneNumber3()
        {
            return mPhoneNumber3;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the email ID
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetEmail(string email)
        {
            mEmail = email;
            TouchRecord();
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the email ID
        /// -------------------------------------------------------------------------------
        /// </summary>
        public string GetEmail()
        {
            return mEmail;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the date the record was created.
        /// -------------------------------------------------------------------------------
        /// </summary>
        public DateTime GetDateCreated()
        {
            return mDateCreated;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the time and date the record was last updated.
        /// -------------------------------------------------------------------------------
        /// </summary>
        public DateTime GetDateLastUpdated()
        {
            return mDateLastUpdated;
        }


        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the ID of the user who creates the new user
        /// -------------------------------------------------------------------------------
        /// </summary>
        public long GetCreatorID()
        {
            return mCreatorUserID;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the ID of the person who calls this fucntion
        /// -------------------------------------------------------------------------------
        /// </summary>
        public void SetActivePerson(Person activeUser)
        {
            mActivePerson = activeUser;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the ID of the currently active user.
        /// -------------------------------------------------------------------------------
        /// </summary>
        static public Person GetActivePerson()
        {
            return mActivePerson;
        }


        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Generates a unique user ID
        /// -------------------------------------------------------------------------------
        /// </summary>
        private long GenerateUserID()
        {
            // record the creator user ID
            if (mActivePerson != null)
            {
                mCreatorUserID = mActivePerson.GetUserID();
            }

            // dump return values rigt now.  To be implemented later.
            return mUserID + 1;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Updates the last updated date
        /// -------------------------------------------------------------------------------
        /// </summary>
        private void TouchRecord()
        {
            mDateLastUpdated = new DateTime();
            if (mActivePerson != null)
            {
                mLastUpdatorID = mActivePerson.GetUserID();
            }
        }

        // Place holder for the currently active user
        static Person mActivePerson;

        //-------------------------------------------------------------------------------
        // Private data region
        //-------------------------------------------------------------------------------
        String mFirstName;
        String mMiddleName;
        String mLastName;
        DateTime mDateOfBirth;
        String mSexType;
        char mUserType;
        String mAddress1;
        String mAddress2;
        String mCity;
        String mState;
        String mPhoneNumber1;
        String mPhoneNumber2;
        String mPhoneNumber3;
        String mEmail;
        String mZipCode;
        long mUserID;
        long mCreatorUserID;
        DateTime mDateCreated;
        DateTime mDateLastUpdated;
        long mLastUpdatorID;
    }
}
